#!/usr/bin/python3
# -*- coding: UTF-8 -*-

import math

'''
啤酒: 2元/瓶
4个瓶盖换/瓶
2个空瓶换/瓶
问: 10元可以喝多少瓶
'''

money = 10
lefCover = 0
lefBottle = 0
drink = money / 2

def beer(cover, bottle):
  global lefCover
  global lefBottle

  if cover >= 4 or bottle >= 2:
    lefCover = cover % 4 + math.floor(bottle / 2) + math.floor(cover / 4)
    lefBottle = bottle % 2 + math.floor(bottle / 2) + math.floor(cover / 4)
    return math.floor(bottle / 2) + math.floor(cover / 4) + beer(lefCover, lefBottle)
  return 0

print('可以喝:{}瓶 剩余: {}个瓶盖 {}个瓶子'.format(drink + beer(5, 5), lefCover, lefBottle))

def fn(x, y = 0, z = 0, n = 0):
    if (x < 2 and y < 4 and z <2):
      print('剩余:{}个瓶盖 {}个瓶子'.format(y, z), end=' ')
      return n
    if (y >= 4): return fn(x, y - 3, z + 1, n + 1)
    if (z >= 2): return fn(x, y + 1, z - 1, n + 1)
    return fn(x - 2, y + 1, z + 1, n + 1)

print('可以喝:{}瓶'.format(fn(10)))
